#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from PIL import Image
import glob, os 

wRatio = 0.78125
hRatio = 0.8
#图片批处理 
def timage(): 
    for files in glob.glob('D:\\\\1111\*.png'):    
        filepath,filename = os.path.split(files) 
        filterame,exts = os.path.splitext(filename) 
        #输出路径 
        opfile = r'D:\\\\2222\\\\'
        #判断opfile是否存在，不存在则创建 
        if (os.path.isdir(opfile)==False): 
            os.mkdir(opfile) 
        im = Image.open(files) 
        w,h = im.size 
        wTarget = round(w*wRatio)
        hTarget = round(h*hRatio)
        im_ss = im.resize((wTarget, hTarget),Image.ANTIALIAS) 
        im_ss.save(opfile+filterame+'.png') 
        print(im_ss.mode)

if __name__=='__main__': 
    timage() 

    print('is  over')

#"""







